package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.dto.onlineservice.EnableStatusReq;
import com.ssy.lingxi.platform.manage.api.model.dto.onlineservice.IdReq;
import com.ssy.lingxi.platform.manage.api.model.dto.onlineservice.OnlineServiceAddReq;
import com.ssy.lingxi.platform.manage.api.model.dto.onlineservice.OnlineServiceUpdateReq;
import com.ssy.lingxi.system.model.request.IdVO;
import com.ssy.lingxi.system.model.response.OnlineServiceDetailRes;
import com.ssy.lingxi.system.model.response.OnlineServicePageRes;
import com.ssy.lingxi.system.service.IOnlineServiceService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 基础设置-在线客服设置
 * @author wyx
 * @version 2.0.0
 * @date 2021-11-16
 */
@RestController
@RequestMapping("/online/service")
public class OnlineServiceController {
    @Resource
    private IOnlineServiceService onlineServiceService;


    /**
     * 新增客服
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> add(@RequestBody @Valid OnlineServiceAddReq req) {
        return onlineServiceService.add(req);
    }

    /**
     * 修改客服
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> update(@RequestBody @Valid OnlineServiceUpdateReq req) {
        return onlineServiceService.update(req);
    }

    /**
     * 启用/停用
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/enable", method = RequestMethod.POST)
    public Wrapper<Void> enable(@RequestBody @Valid EnableStatusReq req) {
        return onlineServiceService.enable(req);
    }

    /**
     * 删除客服配置
     * @param req 请求参数
     * @return 返回结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> delete(@RequestBody @Valid IdReq req) {
        return onlineServiceService.delete(req);
    }

    /**
     * 查看详情
     * @param idVO 请求参数
     * @return 返回结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<OnlineServiceDetailRes> detail(@Valid IdVO idVO) {
        return onlineServiceService.detail(idVO);
    }

    /**
     * 分页查看客服列表
     * @param pageVO 请求参数
     * @return 返回结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<OnlineServicePageRes>> page(PageVO pageVO) {
        return onlineServiceService.page(pageVO);
    }
}
